package com.ibuonline.b2b.gather;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.Socket;

public class DataGatherClient {
	public void upload(File file) {
		BufferedInputStream bis = null;
		BufferedOutputStream bos = null;
		Socket socket = null;
		try {
			bis = new BufferedInputStream(new FileInputStream(file));
			socket = new Socket("192.168.0.81", 8899);
			bos = new BufferedOutputStream(socket.getOutputStream());
			int len;
			byte[] b = new byte[8096];
			while ((len = bis.read(b)) != -1) 
				bos.write(b, 0, len);
			System.out.println("upload completed!");
		} catch(Exception e) {
			e.printStackTrace();
		} finally {
			try {
				if (bis != null)
					bis.close();
				if (bos != null)
					bos.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
	
	public static void main(String[] args) {
		new DataGatherClient().upload(new File("C:/GoldSupplier.zip"));
	}
}
